import React, { Component } from 'react'
import axios from '../request'

export default class Swiper extends Component {
    state = {
        list: []
    }
    render() {
        const { list } = this.state
        return (
            <div>
                <ul>
                    {
                        list.map(item => {
                            return <li key = { item.goods_id }>
                                { item.image_src }
                            </li>
                        })
                    }
                </ul>
            </div>
        )
    }
    componentDidMount() {
        axios.get('https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata').then(list => {
            // res的值和 axios.interceptors.response.use函数的返回值一样
            this.setState({
                list
            })
        })
    }
}
